package reduce.fz.com.reduce.fragment;

import android.content.Intent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.alibaba.fastjson.TypeReference;
import com.squareup.picasso.Picasso;

import java.util.ArrayList;
import java.util.List;

import reduce.fz.com.reduce.R;
import reduce.fz.com.reduce.abstracts.AbResponseListener;
import reduce.fz.com.reduce.adapter.AbstractRecycleHolder;
import reduce.fz.com.reduce.adapter.BaseListAdapter;
import reduce.fz.com.reduce.adapter.BaseListAdapter.BaseListViewHolder;
import reduce.fz.com.reduce.adapter.BaseRecycleViewHolder;
import reduce.fz.com.reduce.bean.ArtistCategory;
import reduce.fz.com.reduce.bean.result.Result;
import reduce.fz.com.reduce.fragment.base.BaseListFragment;
import reduce.fz.com.reduce.util.HttpUtils;

/**
 * Created by qingshengzheng on 15/9/26.
 */
public class FindArtistCategoryFragment extends BaseListFragment<FindArtistCategoryFragment.MyViewHolder, ArtistCategory> {


    @Override
    public MyViewHolder createItemViewHolder(ViewGroup parent) {
    View view=layoutInflater.inflate(R.layout.atrist_category_item,parent,false);
        MyViewHolder holder=new MyViewHolder(view, new ArtistCategoryListener() {
            @Override
            public void onArtistCaategoryClick() {

            }
        });
    return holder;
    }

    public void forwardAtrist()
    {
        Intent intent=new Intent();
        startActivity(intent);
    }


    @Override
    public MyViewHolder createfootViewHolder(View view) {
        MyViewHolder footViewHolder = new MyViewHolder(view);
        return footViewHolder;
    }

    @Override
    public String createReqUrl() {
        return "";
    }

    @Override
    public void request(String url) {
        List<ArtistCategory> test = new ArrayList<ArtistCategory>();
        for (int i = 0; i < 5; i++) {
            test.add(new ArtistCategory());
        }
        baseListAdapter.setFooterNormal();
        baseListAdapter.addDatas(test);
    }


    public   static class MyViewHolder extends BaseRecycleViewHolder<ArtistCategory> {
        private ImageView ivCategory;
        private TextView categoryName;
        private TextView categoryDesc;
        private ArtistCategoryListener listener;

        public MyViewHolder(View itemView, ArtistCategoryListener listener){
            this(itemView);
            this.listener=listener;
        }

        public MyViewHolder(View itemView) {
            super(itemView);
            ivCategory = (ImageView) itemView.findViewById(R.id.iv_category);
            categoryName = (TextView) itemView.findViewById(R.id.category_name);
            categoryDesc = (TextView) itemView.findViewById(R.id.category_desc);
        }

        @Override
        public void renderView(ArtistCategory data, int position) {
            Picasso.with(context).load(R.drawable.atristcategory).into(ivCategory);
        }

        public void initWidget()
        {
            ivCategory.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    listener.onArtistCaategoryClick();
                }
            });
        }

    }
    public interface  ArtistCategoryListener{

        void onArtistCaategoryClick();
    }

}
